/*
 * Attachment.java
 *
 * Created on 18 maart 2008, 12:01
 *
 * @author wijnand.schepens@hogent.be
 */
package model.graphic.objects;

import model.graphic.locations.AbsoluteLocation;
import model.graphic.locations.Location;

/**
 *  a draggable shape that is related to a base-node.
 *  e.g. a resize-handle
 */
public abstract class Attachment extends Graphical {

    protected Graphical base;

    public Attachment() {
    }

    public Attachment(Graphical base, Location location) {
        super.setLocation(location);
        this.base = base;
        this.setLayerLevel(base.getLayerLevel());
    }

    public void adjustLocation(Graphical base, Location loc) {
        super.setLocation(loc);
        this.base = base;
    }

    public void attach(Graphical g) {
        setBase(g);
    }

    public void detach() {
        setLocation(new AbsoluteLocation(getGraphLocation().getX(), getGraphLocation().getY()));
        setBase(null);
    }

    /**
     * @return the baseNode
     */
    public Graphical getBase() {
        return base;
    }

    /**
     * @param baseNode the baseNode to set
     */
    public void setBase(Graphical base) {
        this.base = base;
    }
}
